// 父类
//矩形  可以移动
//属性 宽度 高度 横坐标 纵坐标 x速度 y速度(px/s) 对应don
class dad {
    constructor(width,height,left,top,xspeed,yspeed,dom){
        this.width = width;
        this.height = height;
        this.left = left;
        this.top = top;
        this.xspeed = xspeed;
        this.yspeed= yspeed;
        this.dom = dom;
        this.render();
    }
        render() {//重新渲染坐标
            this.dom.style.width = this.width + "px";
            this.dom.style.height = this.height + "px";
            this.dom.style.left = this.left + "px";
            this.dom.style.top = this.top + "px";

    }

        move(atime) {
            const x = this.xspeed * atime;//横向距离
            const y = this.yspeed * atime;//纵向距离
            const newleft = this.left + x;
            const newtop = this.top + y;

            this.left = newleft;
            this.top = newtop;

            if(this.onMove){
                this.onMove();
            }

            this.render();//重新渲染
    }

    
}

